package sun.nan.test.java;

import java.awt.*;
import javax.swing.*;

public class JTextAreaDemo {
    public static void main(String[] args) {
        try {
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
        }
        JTextArea ta = new JTextArea(20, 20);
        ta.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 5));
        ta.setColumns(0);
        ta.setRows(0);//相当于设置文本区组件的初始大小,并不是说一行只能写0        个字符;
        ta.setLineWrap(false);//设置为禁止自动换行,初始值为false.
        ta.setTabSize(4);//设置制表符的大小为8个字符,初始值为4个字符
        ta.setWrapStyleWord(true);
        ta.setBackground(Color.white);//文本区背景
        ta.setForeground(Color.red);//字体颜色
        ta.setFont(new Font("SansSerif", Font.PLAIN, 14));


        JScrollPane panel = new JScrollPane(ta);
        panel.setPreferredSize(new Dimension(600, 400));
        panel.setBorder(BorderFactory.createMatteBorder(5, 5, 5, 10, Color.white));
        JFrame frame = new JFrame("JTextAreaDemo");//
        frame.setLocation(new Point(212, 184));//Point点是frame左上角点的位置
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(panel);
        frame.pack();
        frame.show();
    }
}